import 'package:flutter/material.dart';
import 'package:flutter_cwhisky/common/style/icons.dart';
import 'package:flutter_cwhisky/component/image_view.dart';
import 'package:flutter_cwhisky/component/text_view.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../bean/mall_home_entity.dart';
import '../../../common/style/colors.dart';
import '../../../common/style/dimens.dart';
import '../../../common/style/style.dart';
import '../mall_good.dart';

class SinglePrefectureComponent extends StatelessWidget {
  final MallHomeDataPrefecture prefecture;

  const SinglePrefectureComponent({Key? key, required this.prefecture}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      clipBehavior: Clip.antiAlias,
      margin: EdgeInsets.only(left: Dimens.horizontalMargin, right: Dimens.horizontalMargin, top: 6.r,bottom: 6.r),
      decoration: BoxDecoration(
          color: AppColors.white, borderRadius: BorderRadius.circular(8.r), boxShadow: AppStyle.commonShadow),
      child: Column(
        children: [
          Container(
            height: 46.r,
            padding: EdgeInsets.only(left: 15.r, right: 15.r),
            decoration: const BoxDecoration(
                gradient: LinearGradient(
                    begin: Alignment.topCenter,
                    end: Alignment.bottomCenter,
                    colors: [Color(0x80F5E9DC), Color(0x00FFEFE6)])),
            child: Row(
              children: [
                Expanded(
                    child: TextView(
                      text: prefecture.name ?? '',
                      fontColor: AppColors.color332B29,
                      fontSize: 16.sp,
                      fontWeight: FontWeight.w500,
                    )),
                Row(
                  children: [
                    TextView(
                      text: '更多',
                      fontColor: AppColors.color99,
                      fontSize: 11.sp,
                    ),
                    Icon(
                      AppIcons.icArrowRight,
                      size: 8.r,
                      color: AppColors.color99,
                    )
                  ],
                )
              ],
            ),
          ),
          Container(
            height: 178.r,
            child: Row(
              children: [
                ImageView(
                  url: prefecture.children![0].image ?? '',
                  width: 100.r,
                ),
                Expanded(
                    child: Column(children: [Divider(height: 0.5.r,color: AppColors.colorE6,),Expanded(child: ListView.builder(
                        physics: const BouncingScrollPhysics(),
                        itemCount: prefecture.goods!.length,
                        scrollDirection: Axis.horizontal,
                        itemBuilder: (context, index) {
                          return Container(
                            margin: EdgeInsets.only(left: 12.r),
                            child: MallGoodView(good: prefecture.goods![index]),
                          );
                        })) ],))
              ],
            ),
          )
        ],
      ),
    );
  }
}
